package com.ruoyi.system.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.system.domain.SysBusinessFinanceRecord;
import com.ruoyi.system.service.ISysBusinessFinanceRecordService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 商家余额记录Controller
 * 
 * @author ruoyi
 * @date 2024-04-14
 */
@RestController
@RequestMapping("/record")
public class SysBusinessFinanceRecordController extends BaseController
{
    @Autowired
    private ISysBusinessFinanceRecordService sysBusinessFinanceRecordService;

    /**
     * 查询商家余额记录列表
     */
    @RequiresPermissions("system:record:list")
    @GetMapping("/list")
    public TableDataInfo list(SysBusinessFinanceRecord sysBusinessFinanceRecord)
    {
        startPage();
        List<SysBusinessFinanceRecord> list = sysBusinessFinanceRecordService.selectSysBusinessFinanceRecordList(sysBusinessFinanceRecord);
        return getDataTable(list);
    }

    /**
     * 导出商家余额记录列表
     */
    @RequiresPermissions("system:record:export")
    @Log(title = "商家余额记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysBusinessFinanceRecord sysBusinessFinanceRecord)
    {
        List<SysBusinessFinanceRecord> list = sysBusinessFinanceRecordService.selectSysBusinessFinanceRecordList(sysBusinessFinanceRecord);
        ExcelUtil<SysBusinessFinanceRecord> util = new ExcelUtil<SysBusinessFinanceRecord>(SysBusinessFinanceRecord.class);
        util.exportExcel(response, list, "商家余额记录数据");
    }

    /**
     * 获取商家余额记录详细信息
     */
    @RequiresPermissions("system:record:query")
    @GetMapping(value = "/info")
    public AjaxResult getInfo(@RequestParam(name = "id",required = true) String  id)
    {
        return success(sysBusinessFinanceRecordService.selectSysBusinessFinanceRecordById(id));
    }

    /**
     * 新增商家余额记录
     */
    @RequiresPermissions("system:record:add")
    @Log(title = "商家余额记录", businessType = BusinessType.INSERT)
    @PostMapping(value = "/add")
    public AjaxResult add(@RequestBody SysBusinessFinanceRecord sysBusinessFinanceRecord)
    {
        return toAjax(sysBusinessFinanceRecordService.insertSysBusinessFinanceRecord(sysBusinessFinanceRecord));
    }

    /**
     * 修改商家余额记录
     */
    @RequiresPermissions("system:record:edit")
    @Log(title = "商家余额记录", businessType = BusinessType.UPDATE)
    @PutMapping(value = "/edit")
    public AjaxResult edit(@RequestBody SysBusinessFinanceRecord sysBusinessFinanceRecord)
    {
        return toAjax(sysBusinessFinanceRecordService.updateSysBusinessFinanceRecord(sysBusinessFinanceRecord));
    }

    /**
     * 删除商家余额记录
     */
    @RequiresPermissions("system:record:remove")
    @Log(title = "商家余额记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/delete/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(sysBusinessFinanceRecordService.deleteSysBusinessFinanceRecordByIds(ids));
    }
}
